﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pseudogenerator.Common.Generators.Core;

namespace Pseudogenerator.Common.Generators
{
    public class Importer
        : MethodBase
    {
        public new string x0 { get; set; }

        public override bool CanGenerateNext
        {
            get { return !string.IsNullOrEmpty(x0); }
        }

        public override uint GetNextValue()
        {
            throw new NotImplementedException();
        }

        public override List<RandomNumber> GetFullList()
        {
            var splited = x0.Split('\n');
            uint i=0;
            var result = new List<RandomNumber>();
            foreach (var item in splited)
            {
                var tmp = 0d;
                if (double.TryParse(item,out tmp))
                {
                    var m = 0;

                    while(tmp.ToString().Contains(".") || tmp.ToString().Contains(","))
                    {
                        tmp = tmp * 10;
                        m++;
                    }

                    result.Add(new RandomNumber((uint)Math.Pow(10, m)) { n = i, Xn = (uint)tmp });
                    i++;
                }
            }

            return result;
        }
    }
}
